package com.wngbms.netty._03buf;

import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;

public class Buf01 {

    public static void main(String[] args) {
        ByteBuf buf = Unpooled.buffer(10);

        p(buf);

        for (int i = 0; i < 4; i++) {
            buf.writeByte(3);
        }

        p(buf);

//        System.out.println(buf.readByte());

        for (int i = 0, m = buf.readableBytes(); i < m; i++) {
            System.out.println(buf.readByte());

        }

        p(buf);
    }

    public static void p(ByteBuf buf) {
        System.out.println("capacity: " + buf.capacity() + "\t" +
                "readerIndex: " + buf.readerIndex() + "\t" +
                "writerIndex: " + buf.writerIndex() + "\t" +
                "readableBytes: " + buf.readableBytes() + "\t" +
                "writableIndex: " + buf.writableBytes());
    }

}
